﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.ADF.BaseClasses;
using System.Drawing;
using PlanningGIS.Framework;

namespace PlanningGIS.Tools.View
{
    /// <summary>
    /// 
    /// </summary>
    public class ShowRecordListButton : BaseCommand
    {/// <summary>
        /// 
        /// </summary>
        IApplication _Application = null;
        
        /// <summary>
        /// 
        /// </summary>
        public ShowRecordListButton()
        {
            m_caption = "显示结果列表";
            m_toolTip = m_caption;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hook"></param>
        public override void OnCreate(object hook)
        {
            if (_Application == null)
            {
                _Application = hook as IApplication;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public override void OnClick()
        {
            //(_Application as IFramework).DockManager.ActivateDockPanel("结果列表");
            if (_Application == null) return;
            IDockManager dock = (_Application as IFramework).DockManager;
            if (dock.DockPanelActivated("结果列表"))
            {
                dock.UnActivateDockPanel("结果列表");
            }
            else
            {
                dock.ActivateDockPanel("结果列表");
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public override int Bitmap
        {
            get
            {
                string bitmapResourceName = "PlanningGIS.Tools.Res.ShowListButton.png";
                return new Bitmap(GetType().Assembly.GetManifestResourceStream(bitmapResourceName)).GetHbitmap().ToInt32();
            }
        }
   
        /// <summary>
        /// 
        /// </summary>
        public override bool Enabled
        {
            get
            {
                return true;
            }
        }
    }
}
